<?php

namespace ExAdmin\ui\component\form\field\upload;

use ExAdmin\ui\component\form\FormItem;
use ExAdmin\ui\Route;
use ExAdmin\ui\support\Request;

class File extends Upload
{
    public $uploadField;
    public function __construct($field = null, $value = '')
    {
        parent::__construct($field, $value);
        $this->progress(false);
        $this->onlyShow(false);
    }

    public function setFormItem(FormItem $formItem)
    {
        parent::setFormItem($formItem); // TODO: Change the autogenerated stub
        $this->action(Request::getSchemeAndHttpHost().'/'.ltrim($this->formItem->form()->attr('url'),'/'));
        $this->uploadField = $this->getValidateField();
        $params = $this->formItem->form()->getCall()['params'];
        $params = array_merge($params,$this->formItem->form()->attr('params') ?? [],['ex_upload_field' => $this->uploadField, 'ex_admin_form_action' => 'upload']);
       
        $this->params($params);
    }
}
